package com.situ.day6;

import org.junit.Test;

public class CalDemo {
	public static void main(String[] args) {
		Add add = new Add(3, 5);
		//Add add = new Add();
		//add.setNum1(3);
		//add.setNum2(5);
		int result = add.getResult();
		System.out.println(result);
	}
	
	@Test
	public void test1() {
		// 你继承谁你就是谁,所有new出来的子类对象都可以赋值给父类变量
		Cal cal = new Add(3, 5);
		int result1 = cal.getResult();
		System.out.println(result1);//8
		cal = new Sub(3, 5);//让父类变量重新指向了new出来的Sub对象
		int result2 = cal.getResult();
		System.out.println(result2);//-2
	}
	
	@Test
	public void test2() {
		//Cannot instantiate the type Cal
		//Cal cal = new Cal(3, 5);//new这个父类其实没有意义
		Add add = new Add(3, 5);
		int result = add.getResult();
		System.out.println(result);
	}
	
	
}
